package com.snimay.xxy;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;

import com.google.gson.Gson;
import com.snimay.common.access.Token;
import com.snimay.common.access.TokenData;

public class test {

	public static void main(String[] args) throws InvalidKeyException, NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException {
		// TODO Auto-generated method stub
		TokenData tdata = new TokenData();
		tdata.userid 	=	123;
		tdata.time 		=	System.currentTimeMillis();
		//tdata.permission=	new ArrayList<>();
	
		/*for(int i=0;i<100;i++) {
			Permission    p =	new Permission();
			p.delete=1;
			p.get	=1;
			p.url	="123fasdfadsfasdfasdfasfd";
			tdata.permission.add(p);
		} */
		String src = new Gson().toJson(tdata);
		System.out.println("len:"+src.length());
		System.out.println(src.getBytes().length);
		Token token = new Token();
		String s = Token.toString(tdata);
		tdata    = Token.get(s);
		System.out.println(s); 
		System.out.println(new Gson().toJson(tdata)); 
		
		/*Decoder decoder = Base64.getDecoder();
		Encoder encoder = Base64.getEncoder();
		
		String privatekey="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMjrs65jpNuRlIyfGQiMVW682ZRqKKycxj9SGVxYis7bVjD7GuLjlbHmcgxGnHI6kU6v3kwAGazM7ZBd3VvAZzECAwEAAQ==";
		
		String s =encoder.encodeToString(privatekey.getBytes());
		
		System.out.println(new String(decoder.decode(s.getBytes()))); */
		
	}

}
